linux 下如何进入 mysql 命令行? |
您所在的位置:网站首页 › linux mysql 进入命令 › linux 下如何进入 mysql 命令行? |
1、在终端中输入mysql -u用户名 -p密码命令可以进行mysql命令行 2、如果密码有特殊字符就先mysql -u用户名 -p回车,然后提示输入密码后,再输入密码回车即可 3、mysql 其它参数说明: mysql命令行参数 Usage: mysql [OPTIONS] [database] //命令方式 -?, --help //显示帮助信息并退出 -I, --help //显示帮助信息并退出 --auto-rehash //自动补全功能,就像linux里面,按Tab键出提示差不多,下面有例子 -A, --no-auto-rehash //默认状态是没有自动补全功能的。-A就是不要自动补全功能 -B, --batch //ysql不使用历史文件,禁用交互 (Enables --silent) --character-sets-dir=name //字体集的安装目录 --default-character-set=name//设置数据库的默认字符集 -C, --compress //在客户端和服务器端传递信息时使用压缩 -#, --debug[=#] //bug调用功能 -D, --database=name //使用哪个数据库 --delimiter=name//mysql默认命令结束符是分号,下面有例子 -e, --execute=name //执行mysql的sql语句 -E, --vertical //垂直打印查询输出 -f, --force //如果有错误跳过去,继续执行下面的 -G, --named-commands /*Enable named commands. Named commands mean this program's internal commandssee mysqlhelp . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.*/ -g, --no-named-commands /*Named commands are disabled. Use \* form only, or use named commands only in the beginning of a line ending with a semicolon () Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecateduse --disable-named-commands instead.*/ -i, --ignore-spaces //忽视函数名后面的空格. --local-infile //启动/禁用 LOAD DATA LOCAL INFILE. -b, --no-beep //sql错误时,禁止嘟的一声 -h, --host=name //设置连接的服务器名或者Ip -H, --html //以html的方式输出 -X, --xml //以xml的方式输出 --line-numbers //显示错误的行号 -L, --skip-line-numbers //忽略错误的行号 -n, --unbuffered//每执行一次sql后,刷新缓存 --column-names //查寻时显示列信息,默认是加上的 -N, --skip-column-names //不显示列信息 -O, --set-variable=name //设置变量用法是--set-variable=var_name=var_value --sigint-ignore //忽视SIGINT符号(登录退出时Control-C的结果) -o, --one-database //忽视除了为命令行中命名的默认数据库的语句。可以帮跳过日志中的其它数据库的更新。 --pager[=name] //使用分页器来显示查询输出,这个要在linux可以用more,less等。 --no-pager //不使用分页器来显示查询输出。 -p, --password[=name] //输入密码 -P, --port=#//设置端口 --prompt=name //设置mysql提示符 --protocol=name //使用什么协议 -q, --quick //不缓存查询的结果,顺序打印每一行。如果输出被挂起,服务器会慢下来,mysql不使用历史文件。 -r, --raw //写列的值而不转义转换。通常结合--batch选项使用。 --reconnect //如果与服务器之间的连接断开,自动尝试重新连接。禁止重新连接,使用--disable-reconnect。 -s, --silent//一行一行输出,中间有tab分隔 -S, --socket=name //连接服务器的sockey文件 --ssl //激活ssl连接,不激活--skip-ssl --ssl-ca=name //CA证书 --ssl-capath=name //CA路径 --ssl-cert=name //X509 证书 --ssl-cipher=name //SSL cipher to use (implies --ssl). --ssl-key=name //X509 密钥名 --ssl-verify-server-cert //连接时审核服务器的证书 -t, --table //以表格的形势输出 --tee=name //将输出拷贝添加到给定的文件中,禁时用--disable-tee --no-tee//根--disable-tee功能一样 -u, --user=name //用户名 -U, --safe-updates //Only allow UPDATE and DELETE that uses keys. -U, --i-am-a-dummy //Synonym for option --safe-updates, -U. -v, --verbose //输出mysql执行的语句 -V, --version //版本信息 -w, --wait //服务器down后,等待到重起的时间 --connect_timeout=# //连接前要等待的时间 --max_allowed_packet=# //服务器接收/发送包的最大长度 --net_buffer_length=# //TCP / IP和套接字通信缓冲区大小。 --select_limit=#//使用--safe-updates时SELECT语句的自动限制 --max_join_size=# //使用--safe-updates时联接中的行的自动限制 --secure-auth //拒绝用(pre-4.1.1)的方式连接到数据库 --server-arg=name //Send embedded server this as a parameter. --show-warnings //显示警告 获取mysql有关的帮助信息,直接在mysql提示符下输入help即可获得有关在mysql客户端相关的帮助信息。这个方式与Oracle SQL*plus下的help 是类似的。 mysqlhelp For information about MySQL products and services, visit: http://www.mysql.com/ For developer information, including the MySQL Reference Manual, visit: http://dev.mysql.com/ To buy MySQL Enterprise support, training, or other products, visit: https://shop.mysql.com/ List of all MySQL commands: Note that all text commands must be first on line and end with '' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. --清除当前输入的语句 connect (\r) Reconnect to the server. Optional arguments are db and host. --重新连接,通常用于被剔除或异常断开后重新连接,SQL*plus下也有这样一个connect命令 delimiter (\d) Set statement delimiter. --设置命令终止符,缺省为;,比如我们可以设定为/来表示语句结束 edit (\e) Edit command with $EDITOR. --编辑缓冲区的上一条SQL语句到文件,缺省调用vi,文件会放在/tmp路径下 ego (\G) Send command to mysql server, display result vertically. --控制结果显示为垂直显示 exit (\q) Exit mysql. Same as quit. --退出mysql go(\g) Send command to mysql server. --发送命令到mysql服务 help (\h) Display this help. nopager (\n) Disable pager, print to stdout.--关闭页设置,打印到标准输出 notee (\t) Don't write into outfile. --关闭输出到文件 pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. --设置pager方式,可以设置为调用more,less等等,主要是用于分页显示 print (\p) Print current command. prompt(\R) Change your mysql prompt. --改变mysql的提示符 quit (\q) Quit mysql. rehash(\#) Rebuild completion hash. --自动补齐相关对象名字 source(\.) Execute an SQL script file. Takes a file name as an argument. --执行脚本文件 status(\s) Get status information from the server.--获得状态信息 system(\!) Execute a system shell command.--执行系统命令 tee (\T) Set outfile [to_outfile]. Append everything into given outfile.-- *** 作结果输出到文件 use (\u) Use another database. Takes database name as argument. --切换数据库 charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. --设置字符集 warnings (\W) Show warnings after every statement. --打印警告信息 nowarning (\w) Don't show warnings after every statement. --上面的所有命令,扩号内的为快捷 *** 作,即只需要输入“\”+ 字母即可执行 For server side help, type 'help contents'--注意这里的描述help contents将获得服务器端的相关帮助信息 --演示部分,演示常用命令 --connect命令 mysqlconnect chardb localhost Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Connection id:5 Current database: chardb --设置分页,在多余一个页面显示时会不停的翻滚,用该命令可以设置分页,设置为调用系统命令 mysqlpager more --设置为more方式 PAGER set to 'more' mysqlselect table_name,table_type,engine from information_schema.tables --该查询会超出一屏显示后按空格键会自动翻滚到下一屏 mysqlpager tail -5 --设置输出尾部5行 PAGER set to 'tail -5' mysqlselect table_name,table_type,engine from information_schema.tables | setup_timers | BASE TABLE | PERFORMANCE_SCHEMA | | threads | BASE TABLE | PERFORMANCE_SCHEMA | | animals | BASE TABLE | InnoDB | | shop | BASE TABLE | InnoDB | +----------------------------------------------+-------------+--------------------+ 92 rows in set (0.02 sec) mysqlpager --查看当前的pager设置 PAGER set to 'tail -5' mysqlnopager --切换到标准(缺省)pager方式 PAGER set to stdout --tee命令,输出日志文件 mysqltee /tmp/query.log--开启输出到文件,相当与SQL*plus下的spool Logging to file '/tmp/query.log' mysqlselect table_name,table_type,engine from information_schema.tables +----------------------------------------------+-------------+--------------------+ | table_name | table_type | engine | +----------------------------------------------+-------------+--------------------+ | CHARACTER_SETS | SYSTEM VIEW | MEMORY | | COLLATIONS | SYSTEM VIEW | MEMORY | ............. mysqlnotee --关闭输出到文件,相当于SQL*Plus下的spool off Outfile disabled. mysqlsystem tail /tmp/query.log--查看输出的日志文件 | setup_consumers | BASE TABLE | PERFORMANCE_SCHEMA | | setup_instruments| BASE TABLE | PERFORMANCE_SCHEMA | | setup_timers | BASE TABLE | PERFORMANCE_SCHEMA | | threads | BASE TABLE | PERFORMANCE_SCHEMA | | animals | BASE TABLE | InnoDB | | shop | BASE TABLE | InnoDB | +----------------------------------------------+-------------+--------------------+ 92 rows in set (0.02 sec) --改变mysql提示符 mysqlprompt SessionA PROMPT set to 'SessionA' --恢复到缺省提示符 SessionAprompt Returning to default PROMPT of mysql --执行sql脚本文件 mysqlsystem more query.sql --注意,此时为当前目录 use chardb select * from tb_isam mysqlsource query.sql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed +------+-------+ | id | value | +------+-------+ |1 | a | |2 | b | |3 | c | |4 | f | +------+-------+ 4 rows in set (0.00 sec) --获取状态信息 mysqlstatus -------------- mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using readline 5.1 Connection id: 6 Current database: chardb Current user: root@localhost SSL:Not in use Current pager: less Using outfile: '' Using delimiter: Server version: 5.5.37-log MySQL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset:latin1 Db characterset:utf8 Client characterset:latin1 Conn. characterset:latin1 UNIX socket:/var/lib/mysql/mysql.sock Uptime: 3 hours 10 min 59 sec Threads: 1 Questions: 97 Slow queries: 0 Opens: 313 Flush tables: 1 Open tables: 51 Queries per second avg: 0.008 -------------- --修改客户端字符集 欢迎分享,转载请注明来源:内存溢出 原文地址:https://outofmemory.cn/zaji/8596803.html |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |